import { Controller, Get, Post, Body, Patch, Param, Delete, Inject } from '@nestjs/common';
import { Aaa7Service } from './aaa7.service';
import { CreateAaa7Dto } from './dto/create-aaa7.dto';
import { UpdateAaa7Dto } from './dto/update-aaa7.dto';
import { EventEmitter2 } from '@nestjs/event-emitter';

@Controller('aaa7')
export class Aaa7Controller {
  constructor(private readonly aaa7Service: Aaa7Service) {}

  @Inject(EventEmitter2)
  private eventEmitter: EventEmitter2

  @Get('sendMail')
  sendMail() {
    this.aaa7Service.sendMail()
  }
  @Get('getMail')
  getMail() {
    this.aaa7Service.reveiveMail()
  }

  @Get('testEventEmitter')
  testEventEmitter() {
    this.eventEmitter.emit('testEventEmitter', {
      data: 'xxx'
    })
    return 'testEventEmitter'
  }

  @Post()
  create(@Body() createAaa7Dto: CreateAaa7Dto) {
    return this.aaa7Service.create(createAaa7Dto);
  }

  @Get()
  findAll() {
    return this.aaa7Service.findAll();
  }

  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.aaa7Service.findOne(+id);
  }

  @Patch(':id')
  update(@Param('id') id: string, @Body() updateAaa7Dto: UpdateAaa7Dto) {
    return this.aaa7Service.update(+id, updateAaa7Dto);
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.aaa7Service.remove(+id);
  }
}
